package labox.innovation.gameserver.skills.conditions;

import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;
import labox.innovation.gameserver.skills.Env;
import labox.innovation.gameserver.templates.item.L2Weapon;

/**
 * @author nBd
 */
public class ConditionChangeWeapon extends Condition {
	private final boolean _required;

	/**
	 * 
	 */
	public ConditionChangeWeapon(boolean required) {
		_required = required;
	}

	/**
	 * @see labox.innovation.gameserver.skills.conditions.Condition#testImpl(labox.innovation.gameserver.skills.Env)
	 */
	@Override
	boolean testImpl(Env env) {
		if (!(env.player instanceof FuzePcInstance))
			return false;

		if (_required) {
			L2Weapon weaponItem = env.player.getActiveWeaponItem();

			if (weaponItem == null)
				return false;

			if (weaponItem.getChangeWeaponId() == 0)
				return false;
		}
		return true;
	}

}